#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
using vi=vector<int>;
using pi=pair<int,int>;

const int N=3e5+5, mod=998244353, i6=(mod+1)/6;
struct mat{
	int a[3][3];
	mat(bool e=0){
		memset(a, 0, sizeof(a));
		a[0][0]=a[1][1]=a[2][2]=e;
	}
	
	friend mat operator*(const mat &A,const mat &B){
		mat res;
		rep(i,0,2){
			rep(j,0,2){
				res.a[i][j]=(A.a[i][0]*B.a[0][j] + A.a[i][1]*B.a[1][j] + A.a[i][2]*B.a[2][j])%mod;
			}
		}
		return res;
	}
};
mat qpow(mat x,int y){
	mat res(1);
	while(y){
		if(y%2) res=res*x;
		x=x*x;
		y/=2;
	}
	return res;
}

int qpow(int x,int y=mod-2){
	int res=1;
	while(y){
		if(y%2) res=res*x%mod;
		x=x*x%mod;
		y/=2;
	}
	return res;
}

int n,k,q;
pi opt[N];
int a[N];

tuple<int,int,int> getinfo(int t){
	int s0=n*(n-1)/2%mod, s1=(n-2)*(n-3)/2%mod;
	
	// a[1][n]=0, sum(a[1])=0, sum(a)=s0
	
	mat trs;
	trs.a[0][0]=(s1-3+mod)%mod, trs.a[0][1]=2, trs.a[0][2]=qpow(s0);
	trs.a[1][1]=(s1+n-3+mod)%mod, trs.a[1][2]=1;
	trs.a[2][2]=s0;
	trs=qpow(trs, t);
	int val=trs.a[0][2]*s0%mod, sum=trs.a[1][2]*s0%mod;
	int d=( ((sum-val*(n-1))%mod+mod)*qpow((n-1)*(n-2)/2%mod) )%mod;
	return {(mod-d)%mod, (val+d*(n-2))%mod, trs.a[2][2]*s0%mod};
}

int F(int n){
	return n*(n-1)%mod*(n-2)%mod*i6%mod;
}

struct BIT{
	vi s;
	BIT(int n){
		s.resize(n);
	}
	void add(int x,int w){
		while(x<(int)s.size()){
			s[x]+= w;
			x+= x&-x;
		}
	}
	int sum(int x){
		int res=0;
		while(x){
			res+= s[x];
			x-= x&-x;
		}
		return res;
	}
};

signed main(){
	freopen("random.in","r",stdin);
	freopen("random.out","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);
	
	cin>>n>>k>>q;
	int s=n*(n-1)/2%mod;
	rep(i,1,n){
		cin>>a[i];
	}
	rep(i,1,q){
		auto &[x,y]=opt[i];
		cin>>x>>y;
		if(x>y){
			swap(x, y);
		}
	}
	
	int cnt=0, dis=0;
	auto getans=[&](int t){
		cnt%=mod, dis%=mod;
		auto [d,val,sum]=getinfo(t);
		int rev=sum*qpow(s)%mod;
		int ans=( (val*(s-cnt)+(rev-val)*cnt) + d*(F(n)-(dis-cnt)*2) )%mod;
		ans=(ans+mod)*qpow(qpow(s, t))%mod;
		return ans;
	};
	
	BIT T0(n+1), T1(n+1);
	per(j,n,1){
		int c=T0.sum(a[j]), s=T1.sum(a[j]);
		cnt+= c, dis+= s-c*j;
		T0.add(a[j], 1);
		T1.add(a[j], j);
	}
	cout<< getans(k) <<'\n';
	rep(i,1,q){
		auto [x,y]=opt[i];
		rep(j,1,x-1){
			if(a[j]>a[x]){
				dis+= y-x;
			}
			if(a[j]>a[y]){
				dis-= y-x;
			}
		}
		rep(j,x+1,y-1){
			if(a[x]>a[j]){
				cnt--, dis-= j-x;
			}
			else{
				cnt++, dis+= y-j;
			}
			if(a[y]>a[j]){
				cnt++, dis+= j-x;
			}
			else{
				cnt--, dis-= y-j;
			}
		}
		rep(j,y+1,n){
			if(a[x]>a[j]){
				dis-= y-x;
			}
			if(a[y]>a[j]){
				dis+= y-x;
			}
		}
		if(a[x]<a[y]){
			cnt++, dis+= y-x;
		}
		else{
			cnt--, dis-= y-x;
		}
		swap(a[x], a[y]);
		cout<< getans(k-i) <<'\n';
	}
}